package com.ucampus.controller;

import com.ucampus.entity.status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ucampus.service.statusService;
/**
 * 功能：
 * 作者： 启明星_Polaris
 * 日期：2025/1/11 下午2:02
 **/

@RestController
@RequestMapping("/status")
public class statusController {
    @Autowired
    private statusService statusService;

    // 根据 userId 查询状态
    @GetMapping("/query")
    public status queryStatusByUserId(@RequestParam("userId") long userId) {
        return statusService.getStatusByUserId(userId);
    }

    // 根据 userId 修改状态
    @PostMapping("/update")
    public String updateStatusByUserId(@RequestParam("userId") long userId, @RequestParam("status") String status) {
        boolean success = statusService.updateStatusByUserId(userId, status);
        if (success) {
            return "Status updated successfully";
        } else {
            return "Failed to update status";
        }
    }
    // 插入记录，仅插入 userId
        @PostMapping("/insert")
    public String insertUserId(@RequestParam("userId") long userId) {
        boolean success = statusService.insertUserId(userId);
        if (success) {
            return "UserId inserted successfully";
        } else {
            return "Failed to insert UserId";
        }
    }
}